/**
* @Author: 858834013@qq.com
* @Name: tabs
* @Date: 2022-05-23
* @Desc: tabs https://www.wanjunshijie.com/note/uniapp/3096.html
<tabLine :list="tablist" :active.sync="active"></tabLine>
*/
<template>
	<div class="tabs">
		<div class="tab cur" :class="{active:active==item.id}" @click="getactive(item.id)" v-for="(item,index) in list"
			:key="index"><span>{{ item.name }}</span>
			<div class="line"></div>
		</div>
	</div>
</template>

<script>
	export default {
		name: "tabs",
		props: {
			list: {
				type: Array,
				default () {
					return [];
				}
			},
			active: {
				type: Number,
				default () {
					return 0;
				}
			},
		},
		methods: {
			getactive(e) {
				this.$emit('update:active', e)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: nowrap;
		flex-direction: row;
		width: 750rpx;
		margin: auto;

		.tab {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-wrap: nowrap;
			flex-direction: column;
			flex: 1;
			position: relative;
			height: 100rpx;

			span {
				font-size: 30rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #646A73;
			}

			.line {
				background: rgba(54, 107, 229, 0);
				border-radius: 4rpx;
				position: absolute;
				bottom: 1rpx;
				width: 100%;
				height: 4rpx;
			}
		}

		.tab.active {
			span {
				color: #7698FF;
			}

			.line {
				background: #4877FF;
			}
		}
	}
</style>
